clear all;

load('comm_loc.mat');
load('input.mat','distance')

comm_loc=comm_loc(:,1:11);
med(1:10,1)=0;
frac_above_low(1:10,1)=0;
frac_above_med(1:10,1)=0;
frac_above_high(1:10,1)=0;

% 87
t=2;[dist87,dist87_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 88
t=3;[dist88,dist88_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 89
t=4;[dist89,dist89_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 90
t=5;[dist90,dist90_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 91
t=6;[dist91,dist91_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 92
t=7;[dist92,dist92_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 93
t=8;[dist93,dist93_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 94
t=9;[dist94,dist94_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 95
t=10;[dist95,dist95_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);
% 96
t=11;[dist96,dist96_closest,med(t-1),...
    frac_above_low(t-1),frac_above_med(t-1),frac_above_high(t-1)]=get_dist(t,comm_loc,distance);

avg_dist=[mean([dist87,dist87_closest]);
    mean([dist88,dist88_closest]);
    mean([dist89,dist89_closest]);
    mean([dist90,dist90_closest]);
    mean([dist91,dist91_closest]);
    mean([dist92,dist92_closest]);
    mean([dist93,dist93_closest]);
    mean([dist94,dist94_closest]);
    mean([dist95,dist95_closest]); 
    mean([dist96,dist96_closest]);];

save('avg_dist.mat','avg_dist','med','frac_above_low','frac_above_med','frac_above_high')